package fristphase.day9_15;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortListDemo2 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("王可晶老师");
        list.add("国斌老师");
        list.add("范传奇老师真的C");
        System.out.println(list);

        //使用Comparator重写Collections的sort方法
        Comparator<String> c = new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return 0;
            }
        };

        Comparator<String> c1 = (String o1,String o2) ->{return 0;};


        Collections.sort(list, new Comparator<String>() {
            public int compare(String o1, String o2) {
                return o1.length()-o2.length();
            }
        });



        //lambda语法糖
        Collections.sort(list,(o2,o1)-> o1.length()-o2.length());

        Collections.sort(list, Comparator.comparingInt(String::length));


        System.out.println(list);
    }
}
